package com.briup.web.controller;

import com.briup.response.Result;
import com.briup.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Slf4j
@Api(tags = "文件上传接口")
@RestController
@RequestMapping("/upload")
public class UploadController {

	@Resource
	private UploadService uploadService;

	@ApiOperation("文件上传")
	@PostMapping
	public Result<String> upload(@RequestPart MultipartFile img) {
		log.info("开始进行文件上传:{}", img.getOriginalFilename());
		return Result.success(uploadService.upload(img));
	}
}
